package view;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class student extends JFrame {
    private JPanel contentPane;

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    student frame = new student();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public student() {
        setTitle("学生考试页面");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 639, 335);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        
        JLabel lblNewLabel = new JLabel("单项选择考试");
        lblNewLabel.setFont(new Font("宋体", Font.BOLD, 25));
        
        JLabel lblNewLabel_1 = new JLabel("1.确保电脑、手机或平板电量充足，网络稳定，并提前测试摄像头、麦克风（如需）。");
        JLabel lblNewLabel_2 = new JLabel("2.不得使用手机、查阅资料或与他人交流，系统可能监控考试行为。");
        JLabel lblNewLabel_3 = new JLabel("3.提交前确认所有题目已完成，避免漏题。");
        JLabel lblNewLabel_4 = new JLabel("4.仔细阅读题目要求，避免因误解题意而失分。");
        JLabel lblNewLabel_5 = new JLabel("请仔细阅读以上注意事项，祝您考试顺利！");
        lblNewLabel_5.setFont(new Font("宋体", Font.PLAIN, 11));
        
        JButton btnNewButton = new JButton("开始考试");
        btnNewButton.setFont(new Font("宋体", Font.BOLD, 15));
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                openpaper(e);
            }
        });
        
        GroupLayout gl_contentPane = new GroupLayout(contentPane);
        gl_contentPane.setHorizontalGroup(
            gl_contentPane.createParallelGroup(Alignment.LEADING)
                .addGroup(gl_contentPane.createSequentialGroup()
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_contentPane.createSequentialGroup()
                            .addGap(199)
                            .addComponent(lblNewLabel))
                        .addGroup(gl_contentPane.createSequentialGroup()
                            .addGap(96)
                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                .addComponent(lblNewLabel_2)
                                .addComponent(lblNewLabel_1)
                                .addComponent(lblNewLabel_3)
                                .addComponent(lblNewLabel_5)
                                .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(btnNewButton)
                                    .addComponent(lblNewLabel_4)))))
                    .addContainerGap(61, Short.MAX_VALUE))
        );
        gl_contentPane.setVerticalGroup(
            gl_contentPane.createParallelGroup(Alignment.LEADING)
                .addGroup(gl_contentPane.createSequentialGroup()
                    .addGap(20)
                    .addComponent(lblNewLabel)
                    .addGap(18)
                    .addComponent(lblNewLabel_1)
                    .addGap(18)
                    .addComponent(lblNewLabel_2)
                    .addGap(18)
                    .addComponent(lblNewLabel_3)
                    .addGap(18)
                    .addComponent(lblNewLabel_4)
                    .addGap(18)
                    .addComponent(lblNewLabel_5)
                    .addPreferredGap(ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                    .addComponent(btnNewButton)
                    .addContainerGap())
        );
        contentPane.setLayout(gl_contentPane);
    }

    protected void openpaper(ActionEvent e) {
        this.dispose(); // 关闭当前窗口
        
        // 创建并显示试卷窗口
        EventQueue.invokeLater(() -> {
            paper frame = new paper();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        });
    }
}